package com.watermoniter.view;

import android.app.Activity;
import android.content.Context;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

import com.watermoniter.util.WMPref;

/**
 * 作者：minj on 2017/9/23 13:19
 * 商品信息的js和android的交互累
 */
public class ProductJsManager {

    private Context mContext;

    public ProductJsManager(Context context){
        mContext=context;
    }

    @JavascriptInterface
    public void showMessage(final String message) {
        ((Activity)mContext).runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(mContext,message,Toast.LENGTH_SHORT).show();
            }
        });
    }

    @JavascriptInterface
    public void setDeviceNo(String deviceNo) {
        WMPref.getInstance(mContext).setDeviceNo(deviceNo);
    }

    @JavascriptInterface
    public void setIP(String ip) {
        WMPref.getInstance(mContext).setIP(ip);
    }

    public String getIP() {
      return   WMPref.getInstance(mContext).getIP();
    }


    public String getDeviceNo() {
        return   WMPref.getInstance(mContext).getDeviceNo();
    }

}



